import request from '@/utils/request'
// 分类：获取文章分类
export const artGetChannelsService = () => request.get('/my/cate/list')
// 分类：添加文章分类
export const artAddChannelService = (data) => request.post('/my/cate/add', data)
// 分类：编辑文章分类
export const artEditChannelService = (data) =>
  request.put('/my/cate/info', data)
// 分类：删除文章分类
export const artDelChannelService = (id) =>
  request.delete('/my/cate/del', {
    params: { id }
  })

// 文章：获取文章列表
export const drugGetListService = (params) =>{
    try {
    const response = await fetch('http://127.0.0.1:8000/queryDrug', {
      method: 'GET'
    });

    if (response.ok) {
      const data = await response.json();
      // 处理 JSON 响应数据
      console.log('Login successful:', data);
      return data;
    } else {
      console.error('Login failed with status:', response.status);
      return null;
    }
  } catch (error) {
    console.error('Error during login:', error);
    return null;
  }
}
// 文章：添加文章
// 注意：data需要是一个formData格式的对象
export const artPublishService = (data) => request.post('/my/article/add', data)

// 文章：获取文章详情
export const artGetDetailService = (id) =>
  request.get('/my/article/info', {
    params: { id }
  })

// 文章：编辑文章接口
export const artEditService = (data) => request.put('/my/article/info', data)

// 文章：删除文章接口
export const artDelService = (id) =>
  request.delete('/my/article/info', { params: { id } })
